package com.xxx.corejava.day1104;

public class Test3 {

    public static void main(String[] args) {


        System.out.println(Test3.rint(3.7));
        System.out.println(Test3.rint(3.3));
        System.out.println(Test3.rint(6.1));
        System.out.println(Test3.rint(65.0));

        System.out.println(rint(4.7));


    }




    public static int rint(double num){
        if(num<0){
            System.out.println("只能对整数做四舍五入");
            return -1;//后期使用异常解决，暂时只是为了语法通过
        }

        int result= (int) (num+0.5);

        return result;

    }


}
